﻿using System; 
using System.Text;
using System.Collections.Generic; 
using System.Data;
using XQ.SP.Model;

namespace XQ.SP.BllServices{
	 	//TestTemp
		public partial class TestTempBLL : BaseBll
	{
   		     
		private readonly XQ.SP.DalServices.TestTempDal dal=new XQ.SP.DalServices.TestTempDal();
		public TestTempBLL()
		{}
		
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool ExistsWhere(string whereSql)
		{
			return dal.ExistsWhere(whereSql);
		}
		
        ///// <summary>
        ///// 是否存在该记录
        ///// </summary>
        //public bool Exists()
        //{
        //    return dal.Exists();
        //}

		
        ///// <summary>
        ///// 增加一条数据
        ///// </summary>
        //public void  Add(XQ.SP.Model.TestTempItem model)
        //{
        //    return dal.Add(model);	
        //}

		/// <summary>
		/// 批量增加数据
		/// </summary>
		public bool  AddList(List<XQ.SP.Model.TestTempItem> models)
		{
            int rows=dal.AddList(models);
            if (rows > 0)
                return true;
            else
                return false;
		}


		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(XQ.SP.Model.TestTempItem model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 批量更新数据
		/// </summary>
		public int UpdateList(List<XQ.SP.Model.TestTempItem> models)
		{
			return dal.UpdateList(models);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			
			return dal.Delete();
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XQ.SP.Model.TestTempItem GetModel()
		{
			
			return dal.GetModel();
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XQ.SP.Model.TestTempItem GetModelWhereStr(string whereSql)
		{
			
			return dal.GetModelWhereStr(whereSql);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere="")
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<XQ.SP.Model.TestTempItem> GetModelList(string strWhere="")
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		
        /// <summary>
        /// 获得新增的数据
        /// </summary>
        public List<XQ.SP.Model.TestTempItem> GetModelListNew(string datetimeStr)
        {
            DataSet ds = dal.GetList(" Created>='"+datetimeStr+"' ");
            return DataTableToList(ds.Tables[0]);
        }
        
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<XQ.SP.Model.TestTempItem> DataTableToList(DataTable dt)
		{
			List<XQ.SP.Model.TestTempItem> modelList = new List<XQ.SP.Model.TestTempItem>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				XQ.SP.Model.TestTempItem model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new XQ.SP.Model.TestTempItem();					
																	model.Temp1= dt.Rows[n]["Temp1"].ToString();
																																model.Temp2= dt.Rows[n]["Temp2"].ToString();
																																model.Temp3= dt.Rows[n]["Temp3"].ToString();
																																model.Temp4= dt.Rows[n]["Temp4"].ToString();
																																model.Temp5= dt.Rows[n]["Temp5"].ToString();
																																model.Temp6= dt.Rows[n]["Temp6"].ToString();
																																model.Temp7= dt.Rows[n]["Temp7"].ToString();
																																model.Temp8= dt.Rows[n]["Temp8"].ToString();
																																model.Temp9= dt.Rows[n]["Temp9"].ToString();
																																model.Temp10= dt.Rows[n]["Temp10"].ToString();
																																model.Temp11= dt.Rows[n]["Temp11"].ToString();
																																model.Temp12= dt.Rows[n]["Temp12"].ToString();
																																model.Temp13= dt.Rows[n]["Temp13"].ToString();
																																model.Temp14= dt.Rows[n]["Temp14"].ToString();
																																model.Temp15= dt.Rows[n]["Temp15"].ToString();
																																model.Temp16= dt.Rows[n]["Temp16"].ToString();
																																model.Temp17= dt.Rows[n]["Temp17"].ToString();
																																model.Temp18= dt.Rows[n]["Temp18"].ToString();
																																model.Temp19= dt.Rows[n]["Temp19"].ToString();
																						
				
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}
		

   
		/// <summary>
		/// Model的属性对应赋值
		/// </summary>
		public void ModelCopy(XQ.SP.Model.TestTempItem modelOld,XQ.SP.Model.TestTempItem modelNew)
		{
			            
            modelNew.Temp1 = modelOld.Temp1;
                        
            modelNew.Temp2 = modelOld.Temp2;
                        
            modelNew.Temp3 = modelOld.Temp3;
                        
            modelNew.Temp4 = modelOld.Temp4;
                        
            modelNew.Temp5 = modelOld.Temp5;
                        
            modelNew.Temp6 = modelOld.Temp6;
                        
            modelNew.Temp7 = modelOld.Temp7;
                        
            modelNew.Temp8 = modelOld.Temp8;
                        
            modelNew.Temp9 = modelOld.Temp9;
                        
            modelNew.Temp10 = modelOld.Temp10;
                        
            modelNew.Temp11 = modelOld.Temp11;
                        
            modelNew.Temp12 = modelOld.Temp12;
                        
            modelNew.Temp13 = modelOld.Temp13;
                        
            modelNew.Temp14 = modelOld.Temp14;
                        
            modelNew.Temp15 = modelOld.Temp15;
                        
            modelNew.Temp16 = modelOld.Temp16;
                        
            modelNew.Temp17 = modelOld.Temp17;
                        
            modelNew.Temp18 = modelOld.Temp18;
                        
            modelNew.Temp19 = modelOld.Temp19;
            		}
#endregion
   
	}
}